HAL RNG types migration

This section provides information about the HAL RNG types migration.

HAL RNG state type definition

HAL1

HAL2

typedef enum
{
    HAL_RNG_STATE_RESET
    HAL_RNG_STATE_READY
    HAL_RNG_STATE_BUSY
    HAL_RNG_STATE_TIMEOUT
    HAL_RNG_STATE_ERROR
} HAL_RNG_StateTypeDef;
typedef enum
{
    HAL_RNG_STATE_RESET
    HAL_RNG_STATE_INIT
    HAL_RNG_STATE_IDLE
    HAL_RNG_STATE_ACTIVE
    HAL_RNG_STATE_ERROR
} hal_rng_state_t;

Related concept: Revised and optimized HAL state machine


HAL RNG callback ID type definition

HAL1

HAL2

typedef enum
{
    HAL_RNG_ERROR_CB_ID
    HAL_RNG_MSPINIT_CB_ID
    HAL_RNG_MSPDEINIT_CB_ID
} HAL_RNG_CallbackIDTypeDef;

Removed.

Note

The callback registration in HAL2 is handled by specific functions for each RNG event. These functions are used to register callback functions for different RNG events. See HAL RNG callbacks register and unregister functions for more details.

Related concept: Individual callback registration APIs replace global register and unregister functions


HAL RNG configuration type definition

  • In HAL1, there are two structures used to configure the RNG: RNG_ConfigTypeDef and RNG_InitTypeDef.

  • In HAL2, these two structures have been merged into a single structure, hal_rng_config_t, with additional separate functions for configuration.

HAL1

HAL2

typedef struct
{
    uint32_t        Config1;
    uint32_t        Config2;
    uint32_t        Config3;
    uint32_t        HealthTest;
    uint32_t        ClockDivider;
    uint32_t        NistCompliance;

    uint32_t        NoiseSource;



    uint32_t        AutoReset;
} RNG_ConfigTypeDef;

typedef struct
{
    uint32_t                    ClockErrorDetection;
} RNG_InitTypeDef;
typedef struct
{
    uint32_t                               config_1;
    uint32_t                               config_2;
    uint32_t                               config_3;
    uint32_t                               health_test;
    hal_rng_clock_divider_t                clock_divider;
    hal_rng_standard_t                     standard;
    hal_rng_clock_error_detection_status_t clock_error_detection;
    hal_rng_noise_source_t                 noise_src;
} hal_rng_config_t;

HAL_RNG_EnableAutoReset(hal_rng_handle_t *hrng);
HAL_RNG_DisableAutoReset(hal_rng_handle_t *hrng);

Related concepts:


HAL RNG handle type definition

HAL1

HAL2

RNG_HandleTypeDef
hal_rng_handle_t

Related concept: Renaming of the handle structure

HAL RNG callback type definition

HAL1

HAL2

pRNG_CallbackTypeDef

and

pRNG_ReadyDataCallbackTypeDef
hal_rng_cb_t

Related concept: Replaced TypeDef suffix with _t in type names